/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.managed.install;

import java.io.Serializable;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
import javax.inject.Named;
import smary.ejb.stateless.auto.UserloginaccountFacade;

/**
 * Prueft mithilfe eines UserloginaccountFacade Objektes ob das Datenmodell
 * bereits fuer den Produktiveinsatz geeignet ist oder ob die Installationsroutine
 * noch von noeten ist.
 * @author llennac
 */
@Named(value="installCheckService")
@Dependent
public class InstallCheckService implements Serializable {
   private boolean installed = false;
   
   @Inject
   UserloginaccountFacade urs;

    public boolean isInstalled() {
        checkInstallation();
        return installed;
    }

    private void setInstalled(boolean installed) {
        this.installed = installed;
    }

    private void checkInstallation() {
        if(urs.count()>0) setInstalled(true);
        else {
            setInstalled(false);
            new InstallationService();
        }
    }

    
}
